package com.xjc.business.controller.buildadmin;

import com.xjc.business.service.BuildingsService;
import com.xjc.system.constants.MyConstants;
import com.xjc.system.exception.MyException;
import com.xjc.system.result.Result;
import com.xjc.system.result.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 徐锦程
 * 时间:2025-03-08 17:53
 */
@RestController
@RequestMapping("/build_admin/build")
public class BuildController {

    @Autowired
    BuildingsService buildingsService;

    /**
     * 获取学校-宿舍楼名称
     * @param id 宿舍楼d
     * @return 学校-宿舍楼名称
     */
    @GetMapping("/getBuildName/{id}")
    public Result<String> getBuildName(@PathVariable(value = "id",required = false) Integer id) {
        if (id == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }

        return buildingsService.getBuildName(id);
    }
}
